<template>
    <router-view />
</template>

<script setup>
import useAppStore from '@/store/modules/app';
const appStore = useAppStore();

const queryStr = location.search;
// const queryStr = '?token=62fb6cacc0534cfebf55ea2f4693eeba&oldCode=11&pathValue=fdsfds,dfsfsd,fdsfs'
const queryStrTmp = queryStr ? queryStr.replace('?', '') : '';
const splitParams = queryStrTmp.split('&');
const queryData = {};

if (splitParams && splitParams.length) {
    for (let i = 0, ii = splitParams.length; i < ii; i++) {
        const item = splitParams[i].split('=');
        if (item[0] === 'pathValues') {
            queryData[item[0]] = item[1].split(',');
        } else {
            queryData[item[0]] = item[1];
        }        
    }

    if (import.meta.env.VITE_APP_ENV === 'development' && false) {
        appStore.setUrlData({
            region: '',
            regionName: '全国',
            defCatalog: '',
            isFromApp: '1',
            input: '',
            // districtCode: '510422100'
        })
    } else {
        appStore.setUrlData(queryData);
    }

    if (queryData.token) {
        const { token, ...other } = queryData;
        appStore.setToken(token);
        appStore.setReginData(other);
    }
}

console.log('url：', queryData)
</script>
